package com.example.sources.util;


import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

/**
 * Created by zhu on 2016/5/24.
 */
public class TestMain {
    public static void main(String[] args) {

        String[] strings = {"acctno","accumulate","aftersale","area","cart","coupont","evaluate","giftcard","goodclass","goodinfo","groupbuy","homepage","mygift","mygoodtest","ordergood","orderinfo","rechargecard","sendbook","source","sourcetmp","useraddress","userinfo"};
        String st = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><model xmlns=\"http://www.justep.com/model\"><action xmlns=\"http://www.w3.org/1999/xhtml\" name=\"queryrng\" impl=\"action:common/CRUD/query\"><private name=\"condition\" type=\"String\"></private><private name=\"db\" type=\"String\">lvfeng</private><private name=\"tableName\" type=\"String\">edg</private><public name=\"columns\" type=\"Object\"></public><public name=\"filter\" type=\"String\"></public><public name=\"limit\" type=\"Integer\"></public><public name=\"offset\" type=\"Integer\"></public><public name=\"orderBy\" type=\"String\"></public><public name=\"variables\" type=\"Object\"></public></action><action xmlns=\"http://www.w3.org/1999/xhtml\" name=\"saverng\" impl=\"action:common/CRUD/save\"><private name=\"db\" type=\"String\">lvfeng</private><private name=\"permissions\" type=\"Object\"><![CDATA[{\"edg\":\"\"}]]></private><public name=\"tables\" type=\"List\"></public></action></model>";
        for (String s:strings){
            String sdd = st.replace("edg", s);
            String first = s.substring(0, 1).toUpperCase();
            String rest = s.substring(1, s.length());
            String Upp = first+rest;
            String asd = sdd.replace("rng", Upp);
            createFile(asd,s);
        }
    }
    public static void createFile(String buff,String fileName){

        String pathName = "D:\\fileName\\"+fileName+".servlet.m";

        try {
            File file = new File(pathName);
            if (!file.exists()){
                file.createNewFile();
            }
            BufferedWriter brW = new BufferedWriter(new FileWriter(pathName));
            brW.write(buff);
            brW.flush();
            brW.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
